<%@ page language="java" import="java.util.*" pageEncoding="UTF8"%>
<%@page import="com.lynn.salary.pojo.TjResultData"%>
<%@page import="com.opensymphony.xwork2.util.ValueStack"%>
<%@page import="org.json.simple.JSONObject"%>
<%@page import="org.json.simple.JSONArray"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
ValueStack vs = (ValueStack) request.getAttribute("struts.valueStack");
TjResultData tjr = (TjResultData)vs.findValue("tjr"); 

%>
<script type="text/javascript">

    var chartContainerId = "chartContainer";
    //----------------------------------------------
    var buildChart = function() {
        YAHOO.widget.Chart.SWFURL = "YUI2/swf/charts.swf";
        YAHOO.namespace("demo");
        YAHOO.demo.salesComparison =
        	<% String abc =  JSONArray.toJSONString(tjr.getData());
        		System.out.println(abc+"");
       		 %>
            <%=abc %>

       
	    /*[
		    { month: "Oct", pork: 4354, beef: 1442 ,abc:2323 },
		    { month: "Nov", pork: 1326, beef: 1496 ,abc:2323 },
		    { month: "Dec", pork: 1292, beef: 1582 ,abc:2323 },
		    { month: "Jan", pork: 1387, beef: 1597 ,abc:2323 },
			{ month: "在请假", pork: 2323, beef: 4343,abc:2323  },
		    { month: "Feb", pork: 1376, beef: 1603 ,abc:2323 }
			{ aname: "" , }
	    ];*/

            var salesData = new YAHOO.util.DataSource(YAHOO.demo.salesComparison);
            salesData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
            salesData.responseSchema = { fields: <%=tjr.getDataFieldsString() %> };

            //--- chart

       <% 
       		abc =  JSONArray.toJSONString(tjr.getSeriesDef());
			System.out.println(abc+"");
		%>
        var seriesDef = 
        	<%=abc %>
	    /*[
		    {
		        yField: "人事部",
		        displayName: "人事部",
		        style:
			    {
			        image: "images/tube.png",
			        mode: "no-repeat",
			        color: 0x2e434d,
			        size: 40
			    }
		    },
		    {
		        yField: "行政部",
		        displayName: "Sales of Beef",
		        style:
			    {
			        image: "images/tube.png",
			        mode: "no-repeat",
			        color: 0xc2d81e,
			        size: 40
			    }
		    },
		    {
		        yField: "研发部 ",
		        displayName: "this is abc",
		        style:
			    {
			        image: "images/tube.png",
			        mode: "no-repeat",
			        color: 0xc2d81e,
			        size: 40
			    }
		    }
	    ];*/

			var mychart = new YAHOO.widget.ColumnChart(chartContainerId, salesData,
	    {
	        series: seriesDef,
	        xField: "<%=tjr.getxFields() %>",
	        style:
		    {
		        border: { color: 0x96acb4, size: 12 },
		        font: { name: "Arial Black", size: 14, color: 0x586b71 },
		        dataTip:
			    {
			        border: { color: 0x2e434d, size: 2 },
			        font: { name: "Arial Black", size: 13, color: 0x586b71 }
			    },
		        xAxis:
			    {
			        color: 0x2e434d
			    },
		        yAxis:
			    {
			        color: 0x2e434d,
			        majorTicks: { color: 0x2e434d, length: 4 },
			        minorTicks: { color: 0x2e434d, length: 2 },
			        majorGridLines: { size: 0 }
			    }
		    }
	    });
    }

    buildChart();
</script>